#pragma once

namespace cyq
{
	template<class Ref,class Ptr,class iterator>
	class reverse_iterator
	{
	public:
		iterator _it;
		typedef reverse_iterator< Ref, Ptr, iterator> Self;

		reverse_iterator(iterator it)
			:_it(it)
		{

		}

		Ref operator*()
		{
			iterator temp(_it);
			return *(--temp);
		}

		Ptr operator->()
		{
			return &(operator*());
		}

		Self& operator++()
		{
			--_it;
			return *this;
		}

		Self operator++(int)
		{
			Self temp(*this);
			--_it;
			return temp;
		}

		Self& operator--()
		{
			++_it;
			return *this;
		}

		Self& operator--(int)
		{
			iterator temp(*this);
			++_it;
			return temp;
		}

		bool operator!=(const Self& s) const
		{
			return _it != s._it;
		}

		bool operator==(const Self& s) const
		{
			return _it == s._it;
		}
	};
}